package com.lottery.material.service.admin.conf.impl;

import com.lottery.material.dao.conf.BankDictMapper;
import com.lottery.material.pojo.conf.BankDict;
import com.lottery.material.service.admin.conf.BankDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description：银行字典服务接口实现类
 * Created by 朱正磊 on 2019-04-13 17:03
 */
@Service("adminBankDictService")
public class BankDictServiceImpl implements BankDictService {

    private final BankDictMapper bankDictMapper;

    @Autowired
    public BankDictServiceImpl(BankDictMapper bankDictMapper) {
        this.bankDictMapper = bankDictMapper;
    }

    /**
     * description：新增一条数据
     * user 朱正磊
     * time 2019-04-20 15:14
     * @param bankDict 对象
     * @return 返回持久化操作数据库状态值
     */
    @Override
    public Integer add(BankDict bankDict) {
        return bankDictMapper.insertSelective(bankDict);
    }

    /**
     * description：根据主键物理删除
     * user 朱正磊
     * time 2019-04-20 15:13
     * @param id 主键
     * @return 返回持久化操作数据库状态值
     */
    @Override
    public Integer deleteById(Integer id) {
        return bankDictMapper.deleteByPrimaryKey(id);
    }

    /**
     * description：根据主键查询唯一数据
     * user 朱正磊
     * time 2019-04-20 15:15
     * @param id 主键
     * @return 返回唯一数据
     */
    @Override
    public BankDict findById(Integer id) {
        return bankDictMapper.selectByPrimaryKey(id);
    }

    /**
     * description：根据主键修改一条数据
     * user 朱正磊
     * time 2019-04-20 15:16
     * @param bankDict 对象
     * @return 返回持久化操作数据库状态值
     */
    @Override
    public Integer updateById(BankDict bankDict) {
        return bankDictMapper.updateByPrimaryKeySelective(bankDict);
    }

    /**
     * description：查询所有数据
     * user 朱正磊
     * time 2019-04-28 17:42
     * @return 返回数据集合
     */
    @Override
    public List<BankDict> findAll() {
        return bankDictMapper.findAll();
    }

    /**
     * description：根据银行编号查询唯一数据
     * user 朱正磊
     * time 2019-04-29 17:10
     * @param bankCode 银行编号
     * @return 返回唯一数据
     */
    @Override
    public BankDict findByBankCode(String bankCode) {
        return bankDictMapper.findByBankCode(bankCode);
    }

}
